//
//  UIButton+BaseButton.m
//  SinaWeibo
//
//  Created by 徐攀 on 16/5/11.
//  Copyright © 2016年 徐攀. All rights reserved.
//

#import "UIButton+BaseButton.h"

@implementation UIButton (BaseButton)

+ (UIButton *)baseButton:(NSString *)title withFontSize:(CGFloat)size backgroundImage:(NSString *)imgName target:(id)obj action:(SEL)selector{
    UIButton *baseButton = [[UIButton alloc] init];
    [baseButton addTarget:obj action:selector forControlEvents:UIControlEventTouchUpInside];
    [baseButton setTitle:title forState:UIControlStateNormal];
    [baseButton setTitleColor:[UIColor darkTextColor] forState:UIControlStateNormal];
    [baseButton setTitleColor:[UIColor orangeColor] forState:UIControlStateHighlighted];
    
    baseButton.titleLabel.font = [UIFont systemFontOfSize:size];
    
    if (imgName.length) {
        
        [baseButton setBackgroundImage:[[UIImage imageNamed:imgName] stretchableImageWithLeftCapWidth:1 topCapHeight:1] forState:UIControlStateNormal];
    }
    
    [baseButton sizeToFit];
    
    return baseButton;
}

@end
